<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload = function(){
            var oDiv = document.getElementById("box1")

            console.log(oDiv.getAttribute("class"))
            console.log(oDiv.getAttribute("xxx"))

            oDiv.setAttribute('ttt','fff')
            oDiv.removeAttribute('xxx')
        }
    </script>
</head>
<body>
    <div id = "box1" class=" box2" title="box3" xxx='yyy'>div</div>
</body>
</html>